<?php

namespace app\index\controller\kefu;

class Base extends \app\BaseController
{
	protected $ChatInfo = [];
    protected function initialize()
	{
        $controller = $this->request->controller();
		$action = $this->request->action();
		$app = app('http')->getName();

		$url =  "{$app}/{$controller}/{$action}";
       
		if (!in_array($url, ['index/kefu.Xiansuo/index'])) {
			$this->checkChatid();
		}
	}

    //检测Chatid
	protected function checkChatid()
	{
        $Chatid = $this->request->header('Authorization');
        $ChatInfo = \app\model\kefu\Xiansuo::where('chatid', $Chatid)->find();
		$ChatInfo['avatarUrl'] = $ChatInfo['fromavatar'];
		if(!empty($ChatInfo)){
			$this->ChatInfo =  $ChatInfo;
		}else{
			abort(50008, '');
		}

    }
}
